package com.zjj.wangluo.tcp;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date
 */
public class ThreadPool {

    private ThreadPoolExecutor pool;

    //此线程池能够处理的最多任务书 = maxPoolSize + queueSize
    public ThreadPool(int maxPoolSize , int queueSize){
        pool = new ThreadPoolExecutor(
                2 , maxPoolSize , 60 , TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(queueSize),
                new ThreadPoolExecutor.AbortPolicy()
        );
    }

    public void exec(Runnable task){
        pool.submit(task);
    }

}
